<?php
/**
 * [商网通 System] Copyright swtshop.cn
 * QQ: 1170787711
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied');
class cart_uqcms extends control
{
    function __construct()
    {
        $this->uid = @$_SESSION['user']['uid'];
        parent::__construct();
    }
    function create_order()
    {
        $arr['address_ch'] = !empty($_POST['address_ch']) ? $_POST['address_ch'] : exit('地址不能为空');
        $arr['message'] = !empty($_POST['message']) ? $_POST['message'] : '';
        $result = $this->module('cart')->create_order($arr);
        $payment = !empty($_POST['payment']) ? $_POST['payment'] : exit('支付方式不能为空');
        if ($result['total_price'] > '0') {
            if ($payment == 'meetpay') {
            } else {
                if ($payment == 'online') {
                    $payArr = array('trade_no' => $result['trade_no'], 'title' => $result['name'], 'pay_price' => $result['total_price']);
                    header("Location:?m=account&a=pay&trade_no=" . $result['trade_no'] . "&payment=" . $payment);
                }
            }
        } else {
            exit('无支付信息');
        }
    }
    function address_ch()
    {
        $id = isset($_GET['id']) ? $_GET['id'] : exit('地址不能为空');
        $row = $this->db->get_one("select id,uid from " . table('member_address') . " where uid = " . $this->uid . " and id = " . $id);
        if ($row['id']) {
            $_SESSION['settle_address'] = $id;
            exit('1');
        }
    }
}